ARG FROM=docker.io/ubuntu:bionic
FROM ${FROM}
LABEL maintainer="pete.birley@att.com"

ARG UBUNTU_RELEASE=bionic
ARG CEPH_RELEASE=mimic
ARG PROJECT=nova
ARG UID=42424
ARG GID=42424

ARG CEPH_REPO=http://download.ceph.com/debian-${CEPH_RELEASE}/
ARG CEPH_KEY=http://download.ceph.com/keys/release.asc

ADD ${CEPH_KEY} /etc/apt/ceph-${CEPH_RELEASE}.key
ADD http://mirrors.huaweicloud.com/repository/conf/Ubuntu-Ports-bionic.list /etc/apt/sources.list

RUN set -ex ;\
    apt-get update; apt-get install -y gnupg2 ;\
    export DEBIAN_FRONTEND=noninteractive ;\
    apt-key add /etc/apt/ceph-${CEPH_RELEASE}.key ;\
    rm -f /etc/apt/ceph-${CEPH_RELEASE}.key ;\
    echo "deb ${CEPH_REPO} ${UBUNTU_RELEASE} main" | tee /etc/apt/sources.list.d/ceph.list ;\
    apt-get update ;\
    apt-get upgrade -y ;\
    apt-get install --no-install-recommends -y \
    ceph-common \
    cgroup-tools \
    dmidecode \
    ebtables \
    iproute2 \
    libvirt-bin \
    pm-utils \
    qemu \
    qemu-block-extra \
    qemu-efi \
    openvswitch-switch \
    kmod qemu-efi-aarch64 xen-utils qemu-kvm 
    ;\
    groupadd -g ${GID} ${PROJECT} ;\
    useradd -u ${UID} -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT} ;\
    mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} ;\
    chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} ;\
    usermod -a -G kvm ${PROJECT} ;\
    apt-get clean -y ;\
    rm -rf \
    /var/cache/debconf/* \
    /var/lib/apt/lists/* \
    /var/log/* \
    /tmp/* \
    /var/tmp/*
